<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">

$inline {{
./purecpp/html/header.html
}}

<body>
<!-- 主体（一般只改变这里的内容） -->
<div class="blog-body">
	<!-- 这个一般才是真正的主体内容 -->
	<div class="blog-container">
		<div class="blog-main">
			<fieldset class="layui-elem-field layui-field-title" style="margin-top: 70px;">
				<legend>编辑文章</legend>
			</fieldset>
			<form class="layui-form blog-editor" method="post" action="/edit_post">

				<div class="layui-form-item">
					<label class="layui-form-label" style="text-align: left;">文章标题</label>
					<div class="layui-input-block">
						<input type="text" name="title" value="${title}" required placeholder="${title}" lay-verify="required" autocomplete="off" class="layui-input">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label" style="text-align: left;">文章类型</label>
					<div class="layui-input-inline">
						<select name="type" lay-verify="required" value="${category}">
							<option value="3">社区开源项目</option>
							<option value="4">代码精粹</option>
							<option value="5">modern c++资讯</option>
							<option value="7">社区活动</option>
							<option value="8">社区精华</option>
							<option value="25">技术探讨</option>
							<option value="47">C++11/14/17/20</option>
							<option value="58">元编程</option>
							<option value="49">社区故事</option>
							<option value="60">社区服务</option>
						</select>
					</div>
				</div>
				<div class="layui-form-item" pane="">
					<input type="post_id" name="post_id" value="${post_id}" class="layui-hide">
				</div>
				<div class="layui-form-item" pane="">
					<input type="post_date" name="post_date" value="${post_date}" class="layui-hide">
				</div>
				<div class="layui-form-item" pane="">
					<div id="post_content"></div>
				</div>
				<div class="clear"></div>
				<div class="layui-form-item">
					<button class="layui-btn" lay-submit="submit" lay-filter="submit">发布</button>
					<button type="reset" class="layui-btn layui-btn-primary">重置</button>
				</div>
			</form>
		</div>
	</div>
</div>
<textarea style="display: none;"  id="pre_md_post_content">${post_content}</textarea>
</body>
  <!--遮罩-->
  <!-- layui.js -->
  <script src="./purecpp/plug/laymd/layui/layui.js"></script>
  <!-- 全局脚本 -->
  <!-- 本页脚本 -->
  <script src="/purecpp/plug/laymd/laymd/marked.min.js"></script>
  <script>
      function HTMLEncode(html) {
          var temp = document.createElement("div");
          (temp.textContent != null) ? (temp.textContent = html) : (temp.innerText = html);
          var output = temp.innerHTML;
          temp = null;
          return output;
      }
      document.getElementById("post_content").innerHTML = HTMLEncode(document.getElementById("pre_md_post_content").value);
      layui.config({base: './purecpp/plug/laymd/laymd/'}).use(['layer', 'laymd','form'], function(){
          var layer = layui.layer,
              form = layui.form,
              laymd = layui.laymd;

          //实例化编辑器,可以多个实例
          var md = laymd.init('post_content', {height:700});

          //内容改变事件
          md.on('change', function () {
              //这里借用marked.js解析效率比HyperDown快,用户可自行找解析器
              this.setPreview(marked(this.getText()));
          });

          //初始化数据预览
          md.do('change');

          form.render('select');
      });
  </script>
</html>